import java.util.Scanner;

//改名字
public class MainE {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[][] arr = new int[n][3];
        for (int i = 0; i < n; i++) {
            arr[i][0] = sc.nextInt(); //x坐标
            arr[i][1] = sc.nextInt(); //y坐标
            arr[i][2] = sc.nextInt(); //半径
        }

        double ret = 0;
        for (int i  = 0; i < n; i++) {
            double sub = Integer.MAX_VALUE;
            for (int j = i + 1; j < n; j++) {
                double num = Math.sqrt(Math.pow(arr[i][0] - arr[j][0], 2) + Math.pow(arr[i][1] - arr[j][1], 2));
                if (num < (double)(arr[i][2] + arr[j][2])) {
                    break;
                } else {
                    sub = Math.min(sub, num - arr[i][2] - arr[j][2]);
                }
            }
            ret += (sub == Integer.MAX_VALUE ? 0 : sub);
        }

        System.out.println(ret);

        sc.close();
    }
}
